<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./vue.js"></script>
</head>

<body>
    <div id="app">
        <input type="button" value="浪起来" @click="fn">
        <input type="button" value="停止" @click="ct">

        <h3>{{ msg }}</h3>
    </div>

    <script>
        Vue.config.productionTip = false;
        new Vue({
            data: {
                msg: '我拿Buff,谢谢~',
                dsq: 0,
            },
            methods: {
                fn() {
                    const that = this
                    if (that.dsq) return
                    that.dsq = 1
                    function cn() {
                        // console.log(that.dsq)
                        that.dsq = setTimeout(function () {
                            const arr = [...that.msg]
                            arr.push(arr[0])
                            arr.shift()
                            that.msg = arr.join('')
                            cn()
                        }, 100)
                    }
                    cn()
                },
                ct() {
                    clearTimeout(this.dsq)
                    this.dsq = 0
                }
            }
        }).$mount('#app')
    </script>
</body>

</html>